module.exports = () => {
    return async function (ctx, next) {
        await next()
        if (ctx.status === 401) {
            ctx.body = ctx.acceptJSON ? { error: 'Unauthorized Error' } : '<h1>Unauthorized Error</h1>'
        }
    }
}